from ogreEx.blender.types import Menu
from ogreEx.ogre.COgreMaterialGenerator import generate_material
from ogreEx.ui.UIClass import OTHER
from ogreEx.wordwrap import wordwrap

@OTHER
class MENU_preview_material_text(Menu):
    bl_label = 'preview'
    @classmethod
    def poll(self,context):
        if context.active_object and context.active_object.active_material:
            return True
    def draw(self, context):
        layout = self.layout
        mat = context.active_object.active_material
        if mat:
            #getConfig()['TOUCH_TEXTURES'] = False
            preview = generate_material( mat )
            for line in preview.splitlines():
                if line.strip():
                    for ww in wordwrap( line ):
                        layout.label(text=ww)